package org.zuel.controller;

import org.zuel.entity.RolePerm;
import org.zuel.service.IRolePermService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.zuel.web.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;

/**
 *  控制器
 *
 * @author ikun
 */
@Api(tags = "管理")
@RestController
@RequestMapping("")
public class RolePermController{

    private IRolePermService rolePermService;

    @Autowired
    public RolePermController(IRolePermService rolePermService){
        this.rolePermService = rolePermService;
    }

    @ApiOperation("查询列表")
    @GetMapping("/rolePerm/list")
    public PageResult<RolePerm> list(HttpServletRequest request) {
        PageParam<RolePerm> pageParam = new PageParam<>(request);
        return rolePermService.list(pageParam);
    }

    @ApiOperation("查询单个")
    @GetMapping("/rolePerm/read/{id}")
    public JsonResult read(@PathVariable("id") Integer id) {
        return rolePermService.read(id);
    }

    @ApiOperation("添加")
    @PostMapping("/rolePerm/add")
    public JsonResult add(@RequestBody RolePerm model) {
    return rolePermService.add(model);
    }

    @ApiOperation("修改")
    @PostMapping("/rolePerm/update")
    public JsonResult update(@RequestBody RolePerm model) {
    return rolePermService.update(model);
    }

    @ApiOperation("删除")
    @GetMapping("/rolePerm/delete/{ids}")
    public JsonResult delete(@PathVariable("ids") Integer[] ids) {
        return rolePermService.delete(ids);
    }

}